package asteroids;

import java.awt.Dimension;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.swing.JOptionPane;


import com.uqbar.vainilla.DesktopGameLauncher;
import com.uqbar.vainilla.Game;

public class AsteroidsGame extends Game{
	
	private Ship nave;
	private List<Asteroid> asteroids;

	@Override
	protected void initializeResources() {
		this.nave = new Ship(this.getDisplayWidth()/2,this.getDisplayWidth()/2);
		this.asteroids = new ArrayList<Asteroid>(Arrays.asList
				(new BigAsteroid(100,100),new BigAsteroid(800,100)
				,new BigAsteroid(100,600),new BigAsteroid(800,600)));
	}

	@Override
	protected void setUpScenes() {
		Level level = new Level();		
		level.addComponent(new Space());
		level.addComponent(this.nave);
		level.addComponents(this.asteroids);		
		this.setCurrentScene(level);
	}

	@Override
	public Dimension getDisplaySize() {
		return new Dimension(900, 700);
	}

	@Override
	public String getTitle() {
		return "Asteroids";
	}
	
	@Override
	public void takeStep(Graphics2D graphics){
		super.takeStep(graphics);		
		
		if(this.asteroids.isEmpty()){
			JOptionPane.showMessageDialog(null, "FELICITACIONES GANASTE EL JUEGO =D");
			System.exit(0);
		}
	}
	
	public static void main(String[] args) {
		new DesktopGameLauncher(new AsteroidsGame()).launch();
	}

	public List<Asteroid> getAsteroids() {
		return asteroids;
	}
	
	public void addAsteroid(Asteroid a){
		this.asteroids.add(a);
	}

}
